const userService = require("../service/user");


// 增
const addUserController = async (ctx,next)=>{
    const results = await userService.addUserService(ctx.request.body);
    if(results){
        ctx.body={
            code:200,
            msg:"sql add success"
        }
    }else{
        ctx.body={
            code:403,
            msg:"sql add error"
        }
    }
}
//删
const deleteUserController = async (ctx,next)=>{
    let results = await userService.deleteUserService(ctx.query);
    if(results){
        ctx.body={
            code:200,
            msg:"sql delete success"
        }
    }else{
        ctx.body={
            code:403,
            msg:"sql delete error"
        }
    }
}
// 改
const updateUserController = async (ctx,next)=>{
    let results = await userService.updateUserService(ctx.request.body);
    if(results){
        ctx.body={
            code:200,
            msg:"sql update success"
        }
    }else{
        ctx.body={
            code:403,
            msg:"sql update error"
        }
    }
}
// 查
const selectUserController = async (ctx,next)=>{
    let results = await userService.selectUserService(ctx.request.body);
    if(results){
        ctx.body={
            code:200,
            msg:"sql select success",
            data:results
        }
    }else{
        ctx.body={
            code:403,
            msg:"sql select error"
        }
    }
}
module.exports = {
    addUserController,
    deleteUserController,
    updateUserController,
    selectUserController,
}